/*  1:   */ package org.intellij.lang.regexp.validation;
/*  2:   */ 
/*  3:   */

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiFileFactory;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.intellij.lang.regexp.RegExpFileType;
import org.intellij.lang.regexp.psi.RegExpClosure;
import org.intellij.lang.regexp.psi.RegExpPattern;
import org.intellij.lang.regexp.psi.RegExpQuantifier;
import org.jetbrains.annotations.NotNull;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */ 
/* 17:   */ class SimplifyQuantifierAction
/* 18:   */   implements IntentionAction
/* 19:   */ {
/* 20:   */   private final RegExpQuantifier a;
/* 21:   */   private final String b;
/* 22:   */   
/* 23:   */   public SimplifyQuantifierAction(RegExpQuantifier paramRegExpQuantifier, String paramString)
/* 24:   */   {
/* 25:36 */     this.a = paramRegExpQuantifier;
/* 26:37 */     this.b = paramString;
/* 27:   */   }
/* 28:   */   
/* 29:   */   @NotNull
/* 30:   */   public String getText()
/* 31:   */   {
/* 32:42 */     String tmp39_33 = ("Replace with '" + this.b + "'");
/* 33:42 */     if (tmp39_33 == null) {
/* 34:42 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/validation/SimplifyQuantifierAction", "getText" }));
/* 35:   */     }
/* 36:42 */     return tmp39_33;
/* 37:   */   }
/* 38:   */   
/* 39:   */   @NotNull
/* 40:   */   public String getFamilyName()
/* 41:   */   {
/* 42:47 */     String tmp2_0 = "Simplify Quantifier";
/* 43:47 */     if (tmp2_0 == null) {
/* 44:47 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/validation/SimplifyQuantifierAction", "getFamilyName" }));
/* 45:   */     }
/* 46:47 */     return tmp2_0;
/* 47:   */   }
/* 48:   */   
/* 49:   */   public boolean isAvailable(@NotNull Project paramProject, Editor paramEditor, PsiFile paramPsiFile)
/* 50:   */   {
/* 51:51 */     if (paramProject == null) {
/* 52:51 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/validation/SimplifyQuantifierAction", "isAvailable" }));
/* 53:   */     }
/* 54:51 */     return this.a.isValid();
/* 55:   */   }
/* 56:   */   
/* 57:   */   public void invoke(@NotNull Project paramProject, Editor paramEditor, PsiFile paramPsiFile)
/* 58:   */     throws IncorrectOperationException
/* 59:   */   {
/* 60:55 */     if (paramProject == null) {
/* 61:55 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/validation/SimplifyQuantifierAction", "invoke" }));
/* 62:   */     }
/* 63:55 */     if (this.b == null)
/* 64:   */     {
/* 65:56 */       this.a.delete();
/* 66:   */     }
/* 67:   */     else
/* 68:   */     {
/* 69:58 */       PsiFileFactory localPsiFileFactory = PsiFileFactory.getInstance(paramProject);
/* 70:   */       
/* 71:60 */       PsiFile localPsiFile = localPsiFileFactory.createFileFromText("dummy.regexp", RegExpFileType.INSTANCE, "a" + this.b + this.a.getType().getToken());
/* 72:61 */       RegExpPattern localRegExpPattern = (RegExpPattern)PsiTreeUtil.getChildOfType(localPsiFile, RegExpPattern.class);
/* 73:62 */       assert (localRegExpPattern != null);
/* 74:   */       
/* 75:64 */       RegExpClosure localRegExpClosure = (RegExpClosure)localRegExpPattern.getBranches()[0].getAtoms()[0];
/* 76:65 */       this.a.replace(localRegExpClosure.getQuantifier());
/* 77:   */     }
/* 78:   */   }
/* 79:   */   
/* 80:   */   public boolean startInWriteAction()
/* 81:   */   {
/* 82:70 */     return true;
/* 83:   */   }
/* 84:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.lang.regexp.validation.SimplifyQuantifierAction

 * JD-Core Version:    0.7.0.1

 */